<?php
class Duihua extends MOD{
	var $act = '';
	var $db = '';
	var $id;
	var $uid;
	var $touid;
	var $offset;
	var $pagesize;
	var $page;
	
	function __construct($act='') 
	{	
		global $db;
		global $table;
		$this->act = $act;
		$this->db = &$db;
		$this->table = DB_PRE.$table;
	}


	function manage()
	{
		global $page,$pagesize;
		//$pagesize = 2;
		$page = $page ? intval($page) : 1;
		$offset = ($page-1)*$pagesize;
		$offset = intval($offset);
		$pagesize = intval($pagesize);
		//return $this->table;
		$sql = "SELECT * FROM $this->table ORDER BY id DESC LIMIT $offset, $pagesize";
		return $this->db->select($sql);
	}

	function edit($id)
	{
		global $id;
			$sql = "SELECT * FROM $this->table WHERE id = $id";
			return $this->db->get_one($sql);
	}

	function del($id)
	{
		global $id;
			$sql = "DELETE FROM $this->table WHERE id = $id";
			return $this->db->query($sql);
	}

	function page()
	{
		global $page,$pagesize;
		$page = $page ? intval($page) : 1;
		$r = $this->db->get_one("SELECT COUNT(*) AS num FROM $this->table");
		$number=$r['num'];
		return showpage($number, $page, $pagesize);
	}










}
?>